/*
 * MIT License
 *
 * Copyright (c) 2024-2048 冰羽
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in all
 * copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 */

package cn.star.framework.dev.entity;

import cn.star.framework.entity.AbstractIdEntity;
import cn.star.framework.extend.type.DatabaseType;
import cn.star.framework.extend.type.PoolType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.Lob;
import javax.persistence.Table;
import lombok.Data;
import org.hibernate.annotations.Comment;

@Data
@Entity
@Table(name = "sys_meta_database")
@org.hibernate.annotations.Table(appliesTo = "sys_meta_database", comment = "关系型数据库连接")
public class MetaDatabase extends AbstractIdEntity {

  @Column(name = "name_", length = 64, nullable = false)
  @Comment("名称")
  private String name;

  @Column(name = "type_", length = 16)
  @Enumerated(EnumType.STRING)
  @Comment("类型")
  private DatabaseType type;

  @Column(name = "catalog_", length = 64)
  @Comment("Catalog")
  private String catalog;

  @Column(name = "schema_", length = 64)
  @Comment("Schema")
  private String schema;

  @Column(name = "url_", nullable = false)
  @Comment("JdbcUrl")
  private String url;

  @Column(name = "username_", length = 64, nullable = false)
  @Comment("用户")
  private String username;

  @Column(name = "password_", length = 64)
  @Comment("密码")
  private String password;

  @Column(name = "driver_", nullable = false)
  @Comment("驱动")
  private String driver;

  @Column(name = "dialect_", nullable = false)
  @Comment("方言")
  private String dialect;

  @Column(name = "pool_type_", length = 16)
  @Comment("连接池类型")
  private PoolType poolType = PoolType.HIKARI;

  @Column(name = "pool_size_", length = 11)
  @Comment("连接池大小")
  private Integer poolSize = 10;

  @Lob
  @Column(name = "extra_")
  @Comment("扩展属性")
  private String extra;
}
